home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group03a.txt
/
000055_icon-group-sender_Thu Mar 27 07:51:13 2003.msg
< prev
next >
Wrap
Internet Message Format
|
2003-12-22
|
6KB
Return-Path: <icon-group-sender>
Received: (from root@localhost)
by baskerville.CS.Arizona.EDU (8.11.1/8.11.1) id h2REnoI09250
for icon-group-addresses; Thu, 27 Mar 2003 07:49:50 -0700 (MST)
Message-Id: <200303271449.h2REnoI09250@baskerville.CS.Arizona.EDU>
X-Newsgroups: comp.lang.icon
Subject: Re: Icon-like programming language - 2 attachments
From: Raja Mukherji <rapl_lang@yahoo.co.uk>
User-Agent: Xnews/5.04.25
X-NNTP-Posting-Host: 10145phys232.ucd.ie
Date: 27 Mar 2003 09:19:01 GMT
To: icon-group@cs.arizona.edu
Errors-To: icon-group-errors@cs.arizona.edu
Status: RO
I've already looked at Idol and Unicon and although they support OOP, they
don't provide operator/function overloading (Unicon says it will, but I
don't think it will be similar to my method). Also, they don't support
currying of functions (although I suppose you could implement it in
Idol/Unicon using classes). However, Rapl was originally written to be a
faster Icon (written in x86 assembly) without looking at the Icon source
code, to see if I could do it. I have since looked at the source code and
feel that extending Icon with new internal types is fairly difficult. I use
a method table for each internal types (much like Jcon) which also makes it
faster (currently Rapl code runs approx 3-5 times faster than Icon although
I haven't tested all features yet).
Part of the reason I wrote Rapl is that at the time, there was no real
attempt to support dynamic native function loading on windows platforms,
which I use (Unicon promises it in the next release but I started Rapl 3
years ago). Rapl doesn't support dynamic loading yet actually, it currently
only supports dynamic linking (all modules are loaded only when needed).
Similarly, it allows initialization of global constants/variables, which
are only initialized when required. The module system provides no way of
telling the difference between native and bytecode module, indeed my
current compiled module file format can contain a mixture of both.
The ease that I think new types can be added to Rapl and the lack of
distinction between native and bytecode modules means (in my opinion) that
the language can be extended fairly easily by independent people at
independant times much more so than Icon.
Also, I wanted to make the language more uniform than Icon, there are no
procedure/record declarations, only constants and variables which may be
assigned functions and types. There are no pre-defined functions, only
imported ones. Everything is an object, including integers, strings, lists,
etc, although internal layering means that performance is not affected as a
results.
Lastly I gave Rapl "symbols", written as .<ident> where there act as simple
immutable values, with the restriction that when any program is running,
.<ident1> = .<ident2> if and only if <ident1> = <ident2>, regardless of
which module they are being used in. (Again this could be done using tables
in Icon but I think my way is faster and simpler). For example, .a, .e, and
.b are used for comparisions (above, equal or below) which can then be
redefined for use in tables/sets for example.
Here's an example of overloading as done in Rapl,
#####################################################################
mod test;
imp sys use write; ## sys is a native module
imp riva use ## riva is the name of the system module
real, ## real is the class of real numbers
Mul, ## Mul is the name of the operator '*'
Add, ## Add is the name of the operator '+'
Comp; ## Comp is used for comparisions
## and is the name of the operator '?'
imp math;
def vector is (
def v is type(X, Y, Z) (
new is ovrl fun() fail; ## constructor
## ovrl <x> = overload with
## default <x>
size is fun() math.sqrt(Self.X^2+Self.Y^2+Self.Z^2);
strn is fun() "(" + Self.X + ", " + Self.Y + ", " +
Self.Z + ")";
);
v.new[real][real][real] <- fun(X, Y, Z) ( ## constructor for reals
Self.X <- X; Self.Y <- Y; Self.Z <- Z;
ret Self;
);
v.new[vector] <- fun(V) ( ## copying constructor for vectors
Self.X <- V.X; Self.Y <- V.Y; Self.Z <- V.Z;
ret Self;
);
Add[vector][vector] <- fun(A, B) vector(A.X+B.X, A.Y+B.Y, A.Z+B.X);
Mul[real][vector] <- fun(K, A) vector(K*A.X, K*A.Y, K*A.Z);
Comp[vector][vector] <- fun(A, B) A.size() ? B.size();
## compare based on size: returns .b, .e or .a
v; ## finally set vector to our temporary type v
);
def start! is ( ## ! = exported symbol
var A <- vector(10.0, 20.0, 10.0);
write(A, "\n"); ## will use A.strn()
var B <- vector(A);
B.X <- 30.0;
write(B, "\n");
var C <- A + B;
var D <- 0.1 * C;
write(D, "\n");
write(if A > D then "A is bigger then
D\n"
else
"A is not bigger than D\n"
);
);
#####################################################################
Anyway, thanks for the comment. I don't think I'm reinventing the wheel,
meerly adding tyres to make it more useful, although I could be wrong...
"Frank J. Lhota" <NOSPAM.lhota.adarose@verizon.net> wrote in
news:UOlga.7606$kU.6828@nwrdny01.gnilink.net:
> My advise is that you should avoid re-inventing the wheel. Some of the
> features of the 'Rapl' are parts of Icon and Icon extensions. For
> example, Icon already supports dynamic loading of other programs (the
> load function for Icon code, the loadfunc function for native code).
> An OO extension of Icon is available through the Idol preprocessor,
> and also through the Unicon language (http://unicon.sourceforge.net/).
> You may want to take a look at these languages before duplicating work
> that has been done already.
>
>
>